{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "e1e2c2aa",
   "metadata": {},
   "source": [
    "编写工资额计算器，要求如下：\n",
    "\n",
    "(1）确定每月的基本工资  \n",
    "(2）输入每月的实际工作天数  \n",
    "（3）输入当月的请假天数  \n",
    "（4）输入当月的加班天数  \n",
    "（5）如果请假天数小于等于2天，对工资无影响；大于2天小于等于7天，扣除当月基本工资的10%；大于7天小于等于14天，扣除当月基本工资的50%；大于14天，扣除全月基本工资。  \n",
    "（6）如果当月实际工作天数和应当工作天数一样（不算加班），则增加基本工资的20%  \n",
    "（7）如果当月有加班，则按照加班的天数和当月的日工资（基本工资/实际工作天数）计算加班费  \n",
    "(6)输入最终应得工资  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1f83432e",
   "metadata": {},
   "outputs": [],
   "source": [
    "standard_work_days = 22\n",
    "\n",
    "basic_salary = float(input(\"Enter the monthly base salary: \"))\n",
    "actual_work_days = float(input(\"Enter the actual number of work days in the month: \"))\n",
    "leave_days = float(input(\"Enter the number of leave days: \"))\n",
    "overtime_days = float(input(\"Enter the number of overtime days: \"))\n",
    "\n",
    "if leave_days <= 2:\n",
    "    deduction = 0\n",
    "elif leave_days <= 7:\n",
    "    deduction = basic_salary * 0.10\n",
    "elif leave_days <= 14:\n",
    "    deduction = basic_salary * 0.50\n",
    "else:\n",
    "    deduction = basic_salary\n",
    "\n",
    "if actual_work_days == standard_work_days:\n",
    "    bonus = basic_salary * 0.20\n",
    "\n",
    "daily_salary = basic_salary / actual_work_days\n",
    "overtime_pay = overtime_days * daily_salary\n",
    "\n",
    "final_salary = basic_salary - deduction + bonus + overtime_pay\n",
    "\n",
    "print(f\"The final salary for the month is: {final_salary:.2f}\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6028809e",
   "metadata": {},
   "source": [
    "将整数 2023 的每个数字分离出来，依次打印输出"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a153fa69",
   "metadata": {},
   "outputs": [],
   "source": [
    "num = 2023\n",
    "for letter in str(num):\n",
    "    print(letter)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "03607136",
   "metadata": {},
   "source": [
    "【简答题】练习2-03：  \n",
    "\n",
    "可能的最小利克瑞尔数: 196\n",
    "\n",
    "---\n",
    "\n",
    "🔢 利克瑞尔数与196的背景  \n",
    "\n",
    "利克瑞尔数（Lychrel Number）是指那些经过反复将其与它的逆序数相加，始终无法产生回文数的自然数​。回文数即是正读和反读都一样的数，例如121、333等。  \n",
    "\n",
    "​核心操作​：对于一个数n，计算n + reverse(n)。如果结果不是回文数，则用结果重复此过程。\n",
    "\n",
    "​196之谜​：196是最小的疑似利克瑞尔数。尽管计算到数亿位，经过数百万次迭代，仍未得到回文数，但这尚未被严格证明，所以196仍被称为\"可能的\"利克瑞尔数。\n",
    "\n",
    "​非利克瑞尔数示例​：例如57，57+75=132，132+231=363，363是回文数，所以57不是利克瑞尔数。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cb394551",
   "metadata": {},
   "outputs": [],
   "source": [
    "def reverse_num(n):\n",
    "    return int(str(n)[::-1])\n",
    "\n",
    "\n",
    "def is_palindrome(n):\n",
    "    return n == reverse_num(n)\n",
    "\n",
    "\n",
    "n = int(input(\"Enter a positive integer:\"))\n",
    "print(f'Number: {n}')\n",
    "\n",
    "while not is_palindrome(n):\n",
    "    print(f\"{n} + {reverse_num(n)} = {n + reverse_num(n)}\")\n",
    "    n += reverse_num(n)\n",
    "\n",
    "print(f\"{n} is not a Lychrel number.\")"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
